package com.scalar.forecast.forecastSetup.actionCommands;

import com.scalar.forecast.actionCommands.ActionCommand;
import com.scalar.forecast.forecastSetup.LevelBean;
import com.scalar.forecast.forecastSetup.forms.ForecastSetupForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;

/**
 * User: Sujan Kumar
 * Date: Feb 10, 2005
 * Time: 12:00:04 PM
 */
public class ForecastSetupAddNewLevelCommand extends ActionCommand
{
    public ActionForward execute ( ActionMapping mapping,
                                            ActionForm form,
                                            HttpServletRequest request,
                                            HttpServletResponse response )
    {
        ForecastSetupForm forecastSetupForm = ( ForecastSetupForm ) form;
        ArrayList levels = forecastSetupForm.getLevels();
        LevelBean levelBean = new LevelBean("","",false);
        levels.add ( levelBean );
        forecastSetupForm.setLevels( levels );
        
        return mapping.findForward ( "forecastSetup" );
    }
}
